<html>
<head>
    <script src="./javascripts/jquery.min.js"></script>
    <script>

        const domain = window.location.href.split('/u.htm')[0]
        $(document).ready(function(){
          document.getElementById('bb').innerHTML = `
            <form action="${domain}" name="ff" method="post" enctype="multipart/form-data" >
              <input type="file" name='f1' id='f1id' onchange="fileDetail(this.files)">
              <input type="submit" value='上传'>
            </form>
          `
        });

        function fileDetail(files){
          console.log(files)
          const file = files[0]
          console.log('file------', file)
          const MB = Math.round(file.size / 1024 / 1024)
          document.getElementById('bb').innerHTML += `
            <div>文件名：${file.name}</div>
            <div>文件大小：${Math.round(file.size / 1024)} <font color="red">KB</font> ${MB <= 0 ? (file.size / 1024 / 1024).toFixed(2) : MB} <font color="red">MB</font> </div>
            <div>文件类型：${file.type}</div>
          `
        }

    </script>
</head>
  <body id="bb">
    
  </body>
</html>